package controllers

import (
	"fmt"
	"strconv"
)

type ReadController struct {
	MainController
}

func (this *ReadController) Post() {
	userFile1 := ".\\models\\data\\1.json"
	userFile2 := ".\\models\\data\\2.json"
	userFile3 := ".\\models\\data\\3.json"
	firstPer, err := ReadFile(userFile1)
	if err != nil {
		fmt.Println("readFile: ", err.Error())
		return
	}
	num1 := strconv.Itoa(len(firstPer))
	secondPer, err2 := ReadFile(userFile2)
	if err2 != nil {
		fmt.Println("readFile: ", err2.Error())
		return
	}
	num2 := strconv.Itoa(len(secondPer))
	thirdlyPer, err3 := ReadFile(userFile3)
	if err3 != nil {
		fmt.Println("readFile: ", err3.Error())
		return
	}
	num3 := strconv.Itoa(len(thirdlyPer))

	this.Data["json"] = map[string]interface{}{
		"success": true,
		"message": "success",
		"first":   map[string]interface{}{"award": "1", "empty": num1, "list": firstPer},
		"second":  map[string]interface{}{"award": "2", "empty": num2, "list": secondPer},
		"thirdly": map[string]interface{}{"award": "3", "empty": num3, "list": thirdlyPer}}
	// pkgname := this.GetString("a")
	this.ServeJSON()
	return
}
